<?php 
	require_once('Connections/con2.php');

	if( isset($_SESSION["autenticado"]) != true){
		header("Location: /sgs/?index.php&pg=login&res=erro");
	}
	
	mysql_select_db($database_con2, $con2);
	$query_rs_div = "SELECT count(*) as total, divisao FROM encaminhamentos group by divisao";
	$rs_div = mysql_query($query_rs_div, $con2) or die(mysql_error());
	$row_rs_div = mysql_fetch_assoc($rs_div);
	$totalRows_rs_div = mysql_num_rows($rs_div);
?>

global por divisao

<form id="form-reldivisao" name="form-reldivisao" method="post" action="" class="form">
	<table width="551">
       	<tr>
			<td width="71"><div align="left">Periodo: </div></td>
            <td width="104"><input name="parametro" type="text" value="" size="15"/></td>
            <td width="21"><div align="center">a </div></td>
			<td width="104"><input name="parametro" type="text" value="" size="15"/></td>
         	<td width="227"><div align="center">
         	  <input name="btnEnviar" type="submit" value="Procurar" class="button" />
         	  <input name="btnLimpar" type="button" value="Limpar" class="button"/>
        	</div></td>
		</tr>
	</table>
</form>

<div id="safe-result">Periodo: 09/09/2012 a 09/10/2012 <br/><hr><br/> Divisao | Quantidade | Concluidas | Porcentagem </div>

<?php 
  $total = 0; 
  
  do { ?>
  <div class="relatorio">    
   <table width="984" border="0">
      <tr>
        <td width="69">Divisao</td>
		<td>Solicitadas</td>     
        <td>Concluidas</td>   
        <td>%</td>                  
      </tr>
      <tr>
        <td width="69"><?php echo $row_rs_div['divisao']; ?></td>
		<td width="69"><?php echo $row_rs_div['total']; ?></td>

      </tr>      
    </table>
   </div>
<?php $total = $total +  $row_rs_div['total'];
  } while ($row_rs_div = mysql_fetch_assoc($rs_div));
	
	echo 'Total: ' . $total;
?>  

<?php
	mysql_free_result($rs_div);
?>
